// MainFrm.cpp : implementation of the CMainFrame class
//
//Chinese food is tasty.  Test
#include "stdafx.h"
#include "GPSwSmartPhone.h"


//Including GPSComm.h in MainFrm.h
#include "MainFrm.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define TOOLBAR_HEIGHT 24

const DWORD dwAdornmentFlags = 0; // exit button

// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	ON_WM_CREATE()
	//ON_COMMAND(ID_MENU_PICKGPSDEVICES, &CMainFrame::OnMenuPickgpsdevices)
END_MESSAGE_MAP()


// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;


	if (!m_wndCommandBar.Create(this) ||
	    !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
	    !m_wndCommandBar.AddAdornments(dwAdornmentFlags) ||
	    !m_wndCommandBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create CommandBar\n");
		return -1;      // fail to create
	}

	m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() | CBRS_SIZE_FIXED);

	//ASP: Added a dialog box call
	//Even if we don't need this, let's just leave it for reference, yeah?
	//LPCTSTR message = L"GPS Client.  Copyright 2010 Steven Schaffer, Raul Alvarado, Alex Puterbaugh"; 
	//LPCTSTR messageCaption = L"Dialog";
	//MessageBox(message, messageCaption, MB_OK);

	//ASP: Bob is now global so it can be accessed by event handlers and whatnot.

	bob = new GPScomm();

	/*bob->useCOM(0);	
	bob->Connect();
	bob->send_binary_mode_string(0);
	bob->read_binary_mode_string(0);
	//bob.store_read_buffer();
	bob->useCOM(2);	
	if(bob->Connect())
	{
		if(bob->open_output_file())
		{
			//bob.send_binary_mode_string(0);
			while(true)
			{
				bob->read_binary_mode_string(0);
				bob->read_binary_mode_string(1);
				bob->read_binary_mode_string(2);
				bob->read_binary_mode_string(3);
				bob->read_binary_mode_string(4);
				// combine reads
				bob->store_read_buffers();
			}
		}
	}
	else // COM port open failed
	{
	}
	return 0;*/
}


BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if (!CFrameWnd::PreCreateWindow(cs))
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

afx_msg void CMainFrame::OnClose()
{
	DestroyWindow();

	// same as double-clicking on main window close box
    ASSERT(AfxGetMainWnd() != NULL);
    AfxGetMainWnd()->SendMessage(WM_CLOSE);

}


// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}
#endif //_DEBUG

// CMainFrame message handlers




void CMainFrame::OnMenuPickgpsdevices()
{
	/*DeviceChooserDialog *chooser = new DeviceChooserDialog();
	chooser->SetCommsObject(bob);
	chooser->Create(IDD_DEVICE_CHOOSER, NULL);
	chooser->ShowWindow(SW_NORMAL);*/
	MessageBox(L"Some", L"stuff", 0);
}
